#ifndef     _CLIENTINFO_H
#define    _CLIENTINFO_H

#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>

typedef struct clientInfo
{
	int connfd;																            //客户端与服务器的已连接标识符fd,同样用来排序插入使用
	struct	sockaddr_in	clientData;							       //当前客户端client有关信息
	struct	clientInfo   *prev;								                 //之前的客户端client有关信息
    struct	clientInfo   *next;								                 //之后的客户端client有关信息
} newClient;

typedef struct clientInfoList
{
    int total;                                                                               //客户端总数
    struct	sockaddr_in	server;							                //server有关信息	
    int listenfd;                                                                         //服务器监听的fd
    newClient  *head;                                                           //头指针
    newClient  *tail;                                                               // 尾指针
} clientList;

void initClientList(clientList* list) ;
newClient* createNewClient(int connfd,struct sockaddr_in clientData);
void append(clientList* list,int  connfd,struct sockaddr_in clientData);
void prepend(clientList* list, int connfd,struct sockaddr_in clientData);
void insertInOrder(clientList* list, int connfd,struct sockaddr_in clientData);
void removeClient(clientList* list, int connfd);
newClient* findClient(const clientList* list, int connfd);
void printList(const clientList* list);

#endif

